import React from 'react'
import {movieListAction} from "../../store/actions/movieActions"
import store from "../../store/store"
import {useDispatch,useSelector} from "react-redux"

export default function Movie() {
  // 推送值上去共享状态
  const dispatch=useDispatch();
  // 从共享状态中拿值
  const count=useSelector((state)=>{
    return state.count.count
  })

  const movieList=useSelector((state)=>{
    return state.movie.movieList
  })

  const movieHandle=()=>{
    dispatch(movieListAction())
  }

  return (
    <div>
      <h1>我是Movie组件</h1>
      <p>我收到的Count组件的值是 {count}</p>

      <ul>
        {
          movieList.map(item=>{
            // react里面render不能直接是对象  
            return <li key={item.tvId}>{item.albumName}</li>;
          })
        }
        console.log(item,'item')
      </ul>
      <button onClick={movieHandle}>电影数据</button>
    </div>
  )
}
